<%@ page pageEncoding="UTF-8"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<html>
    <head>
        <title>客户管理</title>
        <link rel="stylesheet" href="../css/customer_index.css"/>
        <link rel="stylesheet" href="../css/header.css"/>
        <link rel="stylesheet" href="../css/footer.css"/>
        <style type="text/css">
            table.promptbox {background:#FCFCFC;color:#666666;font-family:Arial, Helvetica, sans-serif; font-size:14;width:298;height:200;}
            input.promptbox {border:1 solid #b8c9d6; background-color:#FCFCFC;width:90%;font-family:arial  Helvetica, sans-serif;font-size:13;color:#666666;}
            span{padding-top:8px;padding-left:5px;background:	#FFDAC8;color:#BB3D00;font-size:14px;font-family:Arial, Helvetica, sans-serif; width: 100%;height:30px;}
            
            #thislink a:link{
                font-size:13px;
                font-family:Arial, Helvetica, sans-serif;
                text-decoration: none;
                color:green;                
            }
            
            #thislink a:visited{
                font-size:13px;
                font-family:Arial, Helvetica, sans-serif;
                text-decoration: none;
                color:green;                
            }
            
            #thislink a:hover{
                font-size:13px;
                font-family:Arial, Helvetica, sans-serif;
                color:#930093;          
                text-decoration:underline;
            }
            
            #thislink a:active{
                font-size:13px;
                font-family:Arial, Helvetica, sans-serif;
                text-decoration: none;
                color:		#4F9D9D;                
            }
            
            .customer_icon a:link{
                font-size:13px;
                font-family:Arial, Helvetica, sans-serif;
                text-decoration: none;
                color:		#4F9D9D;                
            }
            
           .customer_icon a:visited{
                font-size:13px;
                font-family:Arial, Helvetica, sans-serif;
                text-decoration: none;
                color:		#4F9D9D;                
            }
            
            .customer_icon a:hover{
                font-size:13px;
                font-family:Arial, Helvetica, sans-serif;
                color:#930093;          
                text-decoration:underline;
            }
            
            .customer_icon a:active{
                font-size:13px;
                font-family:Arial, Helvetica, sans-serif;
                text-decoration: none;
                color:green;                
            }           
            
        </style>    
        <script language="javascript" src="../javascript/sorttable.js"></script>    
        <script language="javascript">
            //分类,将后台获取的分组数据显示，通过javascript动态显示
            function divide(link){
                //获取企业table中的所有行，并查询
                var all_link=document.getElementById('enter_sort').getElementsByTagName('a');
                //循环改变所有链接颜色
                for(var index=0;index<all_link.length;index++)
                {
                    all_link[index].style.color="green";
                }
                link.style.color="red";
                var click_type=link.value;
                var list=(document.getElementById('all_user')).getElementsByTagName('tr');
                
                for(var i=0;i<list.length;i++)
                    list[i].style.display="block";
                   
                if(click_type!="所有企业")
                    for(var j=0;j<list.length;j++)
                {
                    list[j].style.display="none";
                    if((list[j].getElementsByTagName('select'))[0].value==click_type)
                    {
                        list[j].style.display="block";
                    }
                }
            };
            //通过javasccript动态添加出一个浮动框，供用户输入信息
            function prompt2(promptpicture, prompttitle, message, sendto) {

                promptbox = document.createElement('div');
                promptbox.setAttribute ('id' , 'prompt')
                document.getElementsByTagName('body')[0].appendChild(promptbox)
                promptbox = eval("document.getElementById('prompt').style")
                promptbox.position = 'absolute'
                promptbox.top = 200
                promptbox.left = 500
                promptbox.width = 300
                promptbox.border = '1px outset black'
                document.getElementById('prompt').innerHTML = "<span><b>增加分组</b></span>"
                document.getElementById('prompt').innerHTML = document.getElementById('prompt').innerHTML + "<table width='80%' class='promptbox'><tr><td>" + message + "</td></tr><tr><td><input type='text' size='20'id='promptbox' onblur='this.focus()' class='promptbox'></td></tr><tr><td align='center'><br><input type='image' class='prompt' src='../image/logo.PNG' onClick='" + sendto + "(document.getElementById(\"promptbox\").value); document.getElementsByTagName(\"body\")[0].removeChild(document.getElementById(\"prompt\"))'>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<input type='image' class='prompt' src='../image/cancel.png' onClick='" + sendto + "(\"\"); document.getElementsByTagName(\"body\")[0].removeChild(document.getElementById(\"prompt\"))'></td></tr></table>"
                document.getElementById("promptbox").focus()

            }

            function myfunction(value)
            {
                //获取所有分类，并判断所有属性是否与输入的相等
                document.getElementById('get_Type').value=value;
                var exist=document.getElementById('all_user').getElementsByTagName('option');
                var is_exist=false;
                for(var i=0;i<exist.length;i++)
                {
                    if(exist[i].value==value)
                        is_exist=true;
                }
                
                if(value.length>0)
                {
                    if(is_exist==true)
                        alert("此分类名已存在");
                    else{
                        document.add_Type.submit();
                    }
                }
            }
            //修改prompt框，提示用户输入添加分类的组名
            function callPrompt()
            {
                prompt2('', '增加分组','请输入企业新分类组名：', 'myfunction');
            };            

            //显示一个窗口，提供企业的类型，并传至后台,增加分类
            function add_EnterpriseType()
            {
                //获得用户输入的分类名
                var type=prompt("请输入新分类名","");
                document.getElementById('get_Type').value=type;
                //提交的action名
                if (type!=null && type!="")
                {
                    document.add_Type.submit();
                }
            };

            //通过下拉列表改变企业类型，触发此事件，并提交表单
            function change_Type(enterprise_Id,type,form_Id)
            {
                /* alert(enterprise_Id);
            alert(type.value);
            alert(form_Id);*/
            
                var type_name=type.value;
                var list=document.getElementById(form_Id);
                var input_List=list.getElementsByTagName('input');
                input_List[0].value=enterprise_Id;
                input_List[1].value=type_name;
                //            alert(input_List[1].value);
                //            alert(input_List[0].value);
                list.submit();
            };

            //搜索框，遍历所有用户，找到用户的指定的企业，并显示出来
            function search()
            {
                //获得搜索框输入的值，并循环查找
                var temp=document.getElementById('search_blank').value;
                var my_tr=(document.getElementById('all_user')).getElementsByTagName('tr');

                for(var i=0;i<my_tr.length;i++)
                {                    
                    my_tr[i].style.display="none";
                    if((my_tr[i].getElementsByTagName('td'))[0].innerHTML==temp)
                        my_tr[i].style.display="block";
                }
           
            }
        
        </script>

    <body>
        <img src="../image/ok.png"/>
        <div id="container">
            <div id="header">
                <div id="logo">
                </div>
                <div id="menu">
                    <ul>
                        <li><a href="../login">首页</a></li>
                        <li class="tiao"></li>
                        <li><a href="../financial/lookup_Financial">财务</a></li>
                        <li class="tiao"></li>
                        <li><a href="../environment/lookup_Environment">社会环境</a></li>
                        <li class="tiao"></li>
                        <li><a href="../warning/lookup_Warning">警告预警</a></li>
                        <li class="tiao"></li>
                        <li><a href="manage_Enterprise">客户</a></li>
                        <li class="tiao"></li>
                        <li><a href="../upload/lookup_Excel">报表审核</a></li>
                        <li class="tiao"></li>
                        <li><a href="../config/lookup_Config">设置</a></li>
                    </ul>
                </div>
            </div>
            <div id="main">
                <!--左边为所有企业（即用户的显示） 并有搜索分类-->

                <div id="left">
                    <div id="up1">
                    </div>
                    <div id="middle1">
                        <div id="enter_sort" style="float:left">
                            <table width="80%" cellpadding="0" cellspacing="0" align="center">
                                <tr>
                                    <td>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp</td>
                                    <td><input type="text" name="select" id="search_blank" size="10"/>
                                    <input type="image" src="../image/search_submit.gif" height="20px" onClick="search();"/></td>
                                </tr>
                            </table>
                            <br>
                            <table width="100%" border="0" cellpadding="0" cellspacing="0" class="left-table03">
                                <tr>
                                    <td height="29">
                                        <table width="85%" border="0" align="center" cellpadding="0" cellspacing="0">
                                            <tr>
                                                <td width="8%"><img name="img8" id="img8" src="../image/smallico.gif" width="8" height="11" /></td>
                                                <td width="92%">
                                                    <a href="javascript:" class="font" value="所有企业" style="color:red;" onClick="divide(this);" ><b>所有企业</b></a></td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                            </table

                            <s:iterator value="typeList" var="x">

                                <table width="100%" border="0" cellpadding="0" cellspacing="0" class="left-table03">
                                    <tr>
                                        <td height="29">
                                            <table width="85%" border="0" align="center" cellpadding="0" cellspacing="0">
                                                <tr>
                                                    <td width="8%"><img name="img7" id="img7" src="../image/smallico.gif" width="8" height="11" /></td>
                                                    <td width="92%">
                                                        <a href="javascript:" class="font" value="<s:property value='#x.type'/>"onClick="divide(this);" >
                                                            <b><s:property value="#x.type"/></b>
                                                        </a>
                                                    </td>
                                                </tr>
                                            </table>
                                        </td>
                                    </tr>
                                </table>
                            </s:iterator>

                            <br/><br/>
                     <div style="width:100%;height:60px;background:url(../image/chuangjian.png) no-repeat center;cursor:pointer;" onClick="callPrompt();" ></div>
                            <form name="add_Type" action="do_add_EnterpriseType" method="post">
                                <input type="hidden" id="get_Type" name="type.type"/>
                            </form>

                        </div>
                    </div>
                    <div id="buttom1">
                    </div>
                </div>
                <div id="display">
                    <div id="rightup">
                     </div>
                    <div id="rightmiddle">
                        <br>
                    <div id="thislink">    
                    <a href="add_Enterprise" class="font" style="float:right;margin-right: 27px;background:url(../image/add.gif) no-repeat left">&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<b>添加客户</b></a><br/><br/>
                    </div>
                    <table width="95%" style="color:black;"cellpadding="2px" cellspacing="0px" border="1px solid" text-align="center" bordercolor="#BEBEBE"  class="sortable">
                        <thead>
                            <tr>
                                <th width="20%">企业</th>
                                <th width="20%">等级</th>
                                <th width="20%">还款数</th>
                                <th width="15%">还款额度</th>
                                <th width="25%">操作</th>
                            </tr>
                        </thead>
                        <tbody id="all_user">
                            <!--此处为获取后台数据库中企业的信息，并显示在页面上-->
                            <s:iterator value="enterpriseList" var="temp" status="status">
                                <tr>
                                    <td class="customer_icon">
                                        <img  src="../image/user.gif" border="0"/><div style="float:left;margin-top: -25px;padding-left:40px; "><a href="lookup_Enterprise?enterprise.id=<s:property value='#temp.id'/> "><s:property value="#temp.name"/></a></div>
                                        </td>
                                    <td><s:property value="#temp.level"/></td>
                                    <td><s:property value="#temp.name"/></td>
                                    <td><s:property value="#temp.name"/></td>
                                    <td>
                                        <form id="<s:property value='#status.index'/>" action="do_update_Enterprise" method="post">
                                            <select name="enterprise_Type"onChange="change_Type(<s:property value='#temp.id'/>,this,<s:property value='#status.index'/>);">
                                                <s:iterator value="typeList" var="x">
                                                    <s:if test="#temp.enterpriseType.type==#x.type">
                                                        <option value="<s:property value='#x.type'/>" selected>
                                                            <s:property value="#x.type"/>
                                                        </option>
                                                    </s:if>
                                                    <s:else>
                                                        <option value="<s:property value='#x.type'/>"><s:property value="#x.type"/></option>
                                                    </s:else>

                         <!--                   <option value="<s:property value='#x.type'/>"><s:property value="#x.type"/></option> -->
                                                </s:iterator>
                                            </select>
                                            <input type="hidden" name="enterprise.id"/>
                                            <input type="hidden" name="type.type"/>
                                        </form>
                                    </td>
                                </tr>
                            </s:iterator>
                        </tbody>

                    </table>
                    </div>
                    <div id="rightbuttom">
                        </div>
                </div>

            </div>
            <div id="footer">
                <table id="footer-container" border="0" cellpadding="0" cellspacing="0" width="100%" height="100%">
                    <tbody>
                        <tr>
                            <td>
                                <table class="foot-links" border="0" cellpadding="0" cellspacing="0" width="100%">
                                    <tbody>
                                        <tr>
                                            <td><a href="http://www.citigroup.com/" target="_blank">Citigroup.com</a></td>
                                            <td><ul>
                                                    <li><a href="http://www.citi.com.cn/html/cn/about_us/citi_group.html">关于花旗</a></li>
                                                    <li><a href="http://www.citi.com.cn/html/cn/HR/HR.html" target="_blank">加入花旗</a></li>
                                                    <li><a href="https://www.citibank.com.cn/CNGCB/APPS/portal/loadPage.do?path=/info/det/atm_network.htm">分行位置</a></li>
                                                    <li><a href="http://www.citibank.com.cn/chinese/footer/sitemap.htm">网站导航</a></li>
                                                    <li><a href="http://www.citibank.com.cn/chinese/footer/privacy.htm">隐私保护</a></li>
                                                    <li><a href="http://www.citibank.com.cn/chinese/footer/terms.htm">条件与条款</a></li>
                                                </ul>
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <table border="0" cellpadding="0" cellspacing="0" width="100%">
                                    <tbody>
                                        <tr>
                                            <td class="footer-logo"><img src="../image/logo_footer.gif" alt="Citi" title="Citi"></td>
                                            <td class="foot-gray" align="right">沪ICP备05047918<br>
                                                Copyright ? 2011 Citigroup Inc.</td>
                                        </tr>
                                    </tbody>
                                </table>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>

        </div>

    </body>
</html>
